<?php

$config = [
    'id' => 'basic',
    'basePath' => dirname(__DIR__),
    'bootstrap' => ['log'],
    'charset' => 'utf-8',
    'aliases' => [
        '@bower' => '@vendor/bower-asset',
        '@npm' => '@vendor/npm-asset',
        'wpjCode/wii' => '@runtime/wpjCode/wii/src/'
    ],
    'components' => [
        'request' => [
            // !!! insert a secret key in the following (if it is empty) - this is required by cookie validation
            'cookieValidationKey' => 'uM7_kiYGawmDi_2DoFAi1OkaQnE6Db2F',
            "enableCsrfValidation" => false
        ],
        'session' => [
            'name' => 'f23bd81', // session 名称防止多项目混合
            'savePath' => dirname(__DIR__) . '/runtime/session', // 规定session保存目录
        ],
        'cache' => [
            'class' => 'yii\caching\FileCache'
        ],
        'redis' => [
            'class' => 'yii\redis\Connection',
            'hostname' => $_SERVER['REDIS_HOST'],
            'port' => $_SERVER['REDIS_PORT'],
            'database' => $_SERVER['REDIS_DB']
        ],
        'fastCache' => [
            'class' => 'yii\caching\MemCache',
            'servers' => [
                [
                    'host' => $_SERVER['MEM_HOST'],
                    'port' => $_SERVER['MEM_PORT'],
                    'weight' => $_SERVER['MEM_WEIGHT']
                ]
            ],
            'useMemcached' => false // 是否开启[memcached]
        ],
        'user' => [
            'identityClass' => 'app\models\User',
            'enableAutoLogin' => true,
            'loginUrl'=> '/login.html?showHint=1',
        ],
        'errorHandler' => [
            'errorAction' => 'site/error',
        ],
        'mailer' => [
            'class' => 'yii\swiftmailer\Mailer',
            'useFileTransport' => false,//这句一定有，false发送邮件，true只是生成邮件在runtime文件夹下，不发邮件
            'transport' => [
                'class' => 'Swift_SmtpTransport',
                'host' => 'smtp.126.com',  //每种邮箱的host配置不一样
                'username' => '', // 邮件账号
                'password' => '', // 邮件密码
                'port' => '25',
                'encryption' => 'tls',

            ],
            'messageConfig' => [
                'charset' => 'UTF-8',
                'from' => ['wangpengjie369@126.com' => 'admin']
            ],
        ],
        'log' => [
            'traceLevel' => YII_DEBUG ? 3 : 0,
            'targets' => [
                // ************ [接口]日志保存 ************
                [ // PC接口
                    'class' => 'yii\log\FileTarget',
                    'levels' => ['error'],
                    'categories' => ['normal'],
                    'logFile' => '@runtime/logs/pc-api/error/log_' .
                        date('Y-m-d', time()) . '.log'
                ],
                [ // PC接口
                    'class' => 'yii\log\FileTarget',
                    'levels' => ['error'],
                    'categories' => ['pc-api'],
                    'logFile' => '@runtime/logs/pc-api/error/log_' .
                        date('Y-m-d', time()) . '.log'
                ]
            ],
        ],
        'db' => require __DIR__ . '/db.php',
        'urlManager' => [
            'enablePrettyUrl' => true,
            'showScriptName' => false,
            'rules' => require(__DIR__ . '/rule.php')
        ],
        'assetManager' => [
            'bundles' => [
                'yii\web\JqueryAsset' => [
                    'sourcePath' => null,
                    'js' => []
                ],
            ],
        ]
    ],
    'params' => require __DIR__ . '/params.php',
    'modules' => require(__DIR__ . '/modules.php')
];

if (YII_ENV_DEV) {
    // configuration adjustments for 'dev' environment
//    $config['bootstrap'][] = 'debug';
//    $config['modules']['debug'] = [
//        'class' => 'yii\debug\Module',
//        // uncomment the following to add your IP if you are not connecting from localhost.
//        'allowedIPs' => ['*'],
//    ];

    $config['bootstrap'][] = 'wii';
    $config['modules']['wii'] = [
        'class' => 'wpjCode\wii\Module',
        // uncomment the following to add your IP if you are not connecting from localhost.
        'allowedIPs' => ['*'],
    ];
}

return $config;
